package com.guangyunl.b_array;
// 需求: 将arr1[]的元素复制到arr2[]上
public class Demo07_01ArrayCopy {
    public static void main(String[] args) {
        // 定义数组arr1[]
        int[] arr1 = {1,2,3,4,5};
        // 定义数组arr2[]
        int[] arr2 = new int[arr1.length];
        // 循环遍历数组并复制值存储到arr2[]
        System.arraycopy(arr1, 0, arr2, 0, arr1.length);
        //输出arr2[]
        for (int i = 0; i < arr2.length; i++) {
            System.out.println("arr2[" + i + "] = " + arr2[i]);
        }
    }
}

/*
arr2[0] = 1
arr2[1] = 2
arr2[2] = 3
arr2[3] = 4
arr2[4] = 5
 */